$(function () {

    $("form").validationEngine();

    $(".datepicker").datetimepicker({
        format: 'yyyy-mm-dd',
        language: 'zh-CN',
        pickDate: true,
        pickTime: false,
        autoclose:true,
        maxView:4,
        minView: 2,
        todayBtn:true
    });

    //随机颜色
    randomColor = function () {
        return '#' + ('00000' + (Math.random() * 0x1000000 << 0).toString(16)).slice(-6);
    };


    drawCircle = function (rootDomId, size, text) {
        var new_circle = $('<div class="circle">' + text + '</div>');
        new_circle.css({
            'height': size + 'px',
            'width': size + 'px',
            'line-height': size + 'px',
            'background-color': randomColor()
        });
        $('#' + rootDomId).append(new_circle);
    };

    show_sys_modal = function (id) {
        $(document.body).append($('#' + id));
        $('#' + id).modal('show');

    };

    dataScope=function (value1, value2) {
        var getDate = function(str) {
            var tempDate = new Date();
            var list = str.split("-");
            tempDate.setFullYear(list[0]);
            tempDate.setMonth(list[1] - 1);
            tempDate.setDate(list[2]);
            return tempDate;
        }
        var date1 = getDate(value1);
        var date2 = getDate(value2);
        if (date1 > date2) {
            var tempDate = date1;
            date1 = date2;
            date2 = tempDate;
        }
        date1.setDate(date1.getDate());
        var dateArr = [];
        var i = 0;
        while (!(date1.getFullYear() == date2.getFullYear()
        && date1.getMonth() == date2.getMonth() && date1.getDate() == date2
            .getDate())) {
            var dayStr =date1.getDate().toString();
            if(dayStr.length ==1){
                dayStr="0"+dayStr;
            }
            var monthStr=(date1.getMonth() + 1).toString();
            if(monthStr.length==1){
                monthStr="0"+monthStr;
            }
            dateArr[i] = date1.getFullYear() + "-" + monthStr + "-"
                + dayStr;
            i++;
            /*
             * document.write("<div style='display:block'>" + date1.getFullYear() +
             * "-" + (date1.getMonth() + 1) + "-" + date1.getDate() + "</div>");
             */
            // document.write(dateArr[i] + "<br>");
            date1.setDate(date1.getDate() + 1);
        }
        var day_str =date2.getDate().toString();
        if(day_str.length ==1){
            day_str="0"+day_str;
        }
        var month_str=(date2.getMonth() + 1).toString();
        if(month_str.length==1){
            month_str="0"+month_str;
        }
        dateArr.push(date2.getFullYear() + "-" + month_str + "-"
            + day_str);
        return dateArr;
    };




});